package com.bw.module_message.viewmodel

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import com.bw.lib_common.base.BaseViewModel
import com.bw.module_message.model.MessageModel
import com.bw.module_message.repository.MessageRepository
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class MessageViewModel @Inject constructor(private val repository: MessageRepository):BaseViewModel(){

    private val message1 by lazy {
        MutableLiveData<MessageModel>()
    }
    val message1_:LiveData<MessageModel> = message1

    private val message2 by lazy {
        MutableLiveData<MessageModel>()
    }
    val message2_:LiveData<MessageModel> = message2

    private val message3 by lazy {
        MutableLiveData<MessageModel>()
    }
    val message3_:LiveData<MessageModel> = message3
    fun getMessages1(){
        execute(
            action = repository.getMessages("111122223333", 1),
            onError = {

            },
            onFinish = {
                message1.value=it.data
            }
        )
    }
    fun getMessages2(){
        execute(
            action = repository.getMessages("111122223333", 2),
            onError = {

            },
            onFinish = {
                message2.value=it.data
            }
        )
    }
    fun getMessages3(){
        execute(
            action = repository.getMessages("111122223333", 3),
            onError = {

            },
            onFinish = {
                message3.value=it.data
            }
        )
    }
}